package datasv.studentQuery_datasv;

import java.util.Date;

import data.datafactory.DatabaseOperator;
import po.StudentPO;
import resultmessage.StudentQueryRM;

public class UpdateStudentPO {
	public static void main(String[] args) {
		System.out.println(new UpdateStudentPO().updateStudentPO(new StudentPO("001131001","teseStudent",new Date(1992,3,23),"001","department",2013)));
	}
	public StudentQueryRM updateStudentPO(StudentPO po){
		return updateInSql(po);
	}
	private StudentQueryRM updateInSql(StudentPO po){
		DatabaseOperator op=new DatabaseOperator("college");
		if(!op.ifIDExist("student_list", po.getStudentID())){
			return StudentQueryRM.STUDENT_NOT_EXIST;
		}
		StudentQueryRM sr=new DeleteStudent().deleteStudent(po.getStudentID());
		if(!sr.equals(StudentQueryRM.SUCCESS)){
			return sr; 
		}
		sr=new AddStudent().addStudent(po);
		if(!sr.equals(StudentQueryRM.SUCCESS)){
			return sr;
		}
		return sr;
	}
}
